//官方迭代
//创建头节点
var removeElements = function(head, val) {
    const dummyHead = new ListNode(0);
    dummyHead.next = head
    let newHead = dummyHead
    while(newHead.next!==null){
        if(newHead.next.val==val){
            /* const ans = newHead.next */
            newHead.next = newHead.next.next
            /* ans.next = null */
            //这两步是多余的，因为当跳过后，newHead.next不能再被访问，JavaScript 引擎会自动回收无引用的对象
        }else{
            dummyHead = dummyHead.next
        }
    }
    return dummyHead.next
}